home *** CD-ROM | disk | FTP | other *** search
- #include <Movies.h>
- #include <QuickTimeStreaming.h>
- #include <QTStreamingComponents.h>
- #include <FixMath.h>
-
- #include "DoubleFrames.h"
-
- // data structures
-
- typedef struct {
- Component victim;
- UInt32 extras;
- } DoubleFramesSharedGlobalsRecord, **DoubleFramesSharedGlobalsHandle;
-
- typedef struct{
- ComponentInstance self;
- ComponentInstance delegateComponent;
- ComponentInstance target;
- DoubleFramesSharedGlobalsHandle sharedGlobals;
- UInt32 eventCount;
- } DoubleFramesGlobalsRecord, *DoubleFramesGlobalsPtr;
-
- // dispatcher
-
- #define RTPRSSM_BASENAME() DoubleFrames
- #define RTPRSSM_GLOBALS() DoubleFramesGlobalsPtr storage
-
- #define CALLCOMPONENT_BASENAME() RTPRSSM_BASENAME()
- #define CALLCOMPONENT_GLOBALS() RTPRSSM_GLOBALS()
-
- #define COMPONENT_UPP_PREFIX() uppRTPRssm
- #define COMPONENT_DISPATCH_FILE "DoubleFramesDispatch.h"
- #define COMPONENT_SELECT_PREFIX() kRTPRssm
-
- #define GET_DELEGATE_COMPONENT() (storage->delegateComponent)
-
- #include "QTStreamingComponents.k.h"
- #include "ComponentDispatchHelper.c"
-
- // code
-
- pascal ComponentResult DoubleFramesOpen(DoubleFramesGlobalsPtr glob, ComponentInstance self)
- {
- ComponentResult err;
- DoubleFramesSharedGlobalsHandle sharedGlobals;
-
- glob = (DoubleFramesGlobalsPtr)NewPtrClear(sizeof(DoubleFramesGlobalsRecord));
- err = MemError();
- if (noErr != err) goto bail;
-
- SetComponentInstanceStorage(self, (Handle)glob);
- glob->self = self;
- glob->target = self;
-
- sharedGlobals = (DoubleFramesSharedGlobalsHandle)GetComponentRefcon((Component)self);
- if (!sharedGlobals) {
- Component victim;
- ComponentDescription cd;
-
- GetComponentInfo((Component)self, &cd, nil, nil, nil);
- cd.componentManufacturer = kVictimManufacturer;
- cd.componentFlags = 0;
- cd.componentFlagsMask = 0;
- victim = FindNextComponent(nil, &cd);
- if (!victim) {
- DebugStr("\p couldn't find victim!");
- err = paramErr;
- goto bail;
- }
-
- sharedGlobals = (DoubleFramesSharedGlobalsHandle) NewHandleSysClear(sizeof(DoubleFramesSharedGlobalsRecord));
- if (!sharedGlobals) {
- err = MemError();
- goto bail;
- }
- SetComponentRefcon((Component)self, (long)sharedGlobals);
-
- victim = CaptureComponent(victim, (Component)self);
- if (!victim) {
- err = paramErr;
- goto bail;
- }
- (**sharedGlobals).victim = victim;
- (**sharedGlobals).extras = 1;
- }
-
- glob->sharedGlobals = sharedGlobals;
- err = OpenAComponent((**sharedGlobals).victim, &glob->delegateComponent);
- if (err) goto bail;
-
- ComponentSetTarget(glob->delegateComponent, self);
-
- bail:
- return err;
- }
-
- pascal ComponentResult DoubleFramesRegister(DoubleFramesGlobalsPtr glob)
- {
- // If we get this far, we must have been opened successfully, so all is well.
- return noErr;
- }
-
- pascal ComponentResult DoubleFramesUnregister(DoubleFramesGlobalsPtr glob)
- {
- UncaptureComponent((**glob->sharedGlobals).victim);
- DisposeHandle((Handle)glob->sharedGlobals);
- return noErr;
- }
-
- pascal ComponentResult DoubleFramesClose(DoubleFramesGlobalsPtr glob, ComponentInstance self)
- {
- if (glob) {
- if (glob->delegateComponent)
- CloseComponent(glob->delegateComponent);
-
- DisposePtr((Ptr)glob);
- }
-
- return noErr;
- }
-
- pascal ComponentResult DoubleFramesTarget(DoubleFramesGlobalsPtr glob, ComponentInstance target)
- {
- glob->target = target;
- if (glob->delegateComponent)
- ComponentSetTarget(glob->delegateComponent, target);
-
- return noErr;
- }
-
- pascal ComponentResult DoubleFramesVersion(DoubleFramesGlobalsPtr glob)
- {
- return CallComponentVersion(glob->delegateComponent);
- }
-
- static Boolean capsLockIsDown(void)
- {
- KeyMapByteArray keys;
- GetKeys((UInt32*)keys);
- return (keys[7] & 2) ? true : false;
- }
-
- pascal ComponentResult DoubleFramesSendChunkAndDecrRefCount(DoubleFramesGlobalsPtr glob, SHChunkRecord *inChunk, const SHServerEditParameters * inServerEdit)
- {
- if( inChunk ) {
- UInt32 count = (**glob->sharedGlobals).extras;
- while( count-- ) {
- RTPRssmIncrChunkRefCount( glob->delegateComponent, inChunk );
- RTPRssmSendChunkAndDecrRefCount( glob->delegateComponent, inChunk, inServerEdit );
- }
- }
- return RTPRssmSendChunkAndDecrRefCount( glob->delegateComponent, inChunk, inServerEdit );
- }
-
-